home *** CD-ROM | disk | FTP | other *** search
/ EnigmA Amiga Run 1995 October / EnigmA AMIGA RUN 01 (1995)(G.R. Edizioni)(IT)[!][issue 1995-10][Aminet 7].iso / Aminet / dev / gui / gengui2.lha / GenGui2 / Examples / palette.gui < prev    next >
Text File  |  1995-02-09  |  3KB  |  160 lines

  1.  
  2. #c_source
  3.  
  4. #include <exec/types.h>
  5. #include <proto/graphics.h>
  6.  
  7. #define RED   1
  8. #define GREEN 2
  9. #define BLUE  3
  10. #define PALETTE 0
  11. #define PLUS 4
  12. #define MINUS 5
  13.  
  14. int PaletteHook(struct IntuiMessage *msg);
  15. int RedHook(struct IntuiMessage *msg);
  16. int GreenHook(struct IntuiMessage *msg);
  17. int BlueHook(struct IntuiMessage *msg);
  18.  
  19. /* We cannot write these functions here, since some values of the GUI are
  20.    not declared/defined yet, but we need the prototype */
  21.  
  22. #include "backfillhook.h"
  23.  
  24. struct Hook clear={{0,0},HookFunc,0,COLOR(0,0)};
  25.  
  26.  
  27. #end_source
  28.  
  29. projectname TestPro
  30.  
  31. vbox
  32.  
  33.  
  34.    HBox
  35.  
  36.       FRAME raised
  37.       backfill &clear
  38.  
  39.       vbox
  40.          xchar 3*2
  41.          xpix  2*INTERWIDTH+3*4  // 2 * Spacing + 3 Sliders
  42.  
  43.          hbox
  44.             Slider
  45.                xchar 2
  46.                xpix  4
  47.                id RED
  48.                hook RedHook
  49.                tags PGA_Freedom,LORIENT_VERT
  50.                tags GTSL_LevelPlace,PLACETEXT_BELOW
  51.                tags GTSL_LevelFormat,(ULONG)"%2ld"
  52.                tags GTSL_MaxLevelLen,2
  53.             end
  54.             Slider
  55.                xchar 2
  56.                xpix  4
  57.                id GREEN
  58.                hook GreenHook
  59.                tags PGA_Freedom,LORIENT_VERT
  60.                tags GTSL_LevelPlace,PLACETEXT_BELOW
  61.                tags GTSL_LevelFormat,(ULONG)"%2ld"
  62.                tags GTSL_MaxLevelLen,2
  63.             end
  64.             Slider
  65.                xchar 2
  66.                xpix  4
  67.                id BLUE
  68.                hook BlueHook
  69.                tags PGA_Freedom,LORIENT_VERT
  70.                tags GTSL_LevelPlace,PLACETEXT_BELOW
  71.                tags GTSL_LevelFormat,(ULONG)"%2ld"
  72.                tags GTSL_MaxLevelLen,2
  73.             end
  74.          end
  75.          vbox
  76.             stdline 1
  77.          end
  78.       end
  79.       palette
  80.          id PALETTE
  81.          hook PaletteHook
  82.          tags GTPA_Depth,2
  83.          tags GTPA_IndicatorWidth,20
  84.       end
  85.    end
  86.  
  87.    hbox
  88.       stdline 1
  89.       button
  90.          text "+"
  91.          id 4
  92.       end
  93.       vbox
  94.       end
  95.       button
  96.          text "-"
  97.          id 5
  98.       end
  99.    end
  100. end
  101.  
  102.  
  103.  
  104. #c_source
  105. int ActiveColor=1;
  106. int Red;
  107. int Green;
  108. int Blue;
  109.  
  110. int PaletteHook(struct IntuiMessage *msg)
  111. {
  112.    ULONG rgb;
  113.  
  114.    if(msg) ActiveColor=msg->Code; // This function is also called from
  115.                                   // Custom(), then msg is 0
  116.  
  117.    rgb=GetRGB4(TestPro.Window->WScreen->ViewPort.ColorMap,ActiveColor);
  118.  
  119.    Red=rgb>>8;
  120.    rgb&=0xff;
  121.    Green=rgb>>4;
  122.    rgb&=0xf;
  123.    Blue=rgb;
  124.  
  125.    GG_SetGadgetAttrs(TestPro_Gadgets[TestPro_RED],TestPro.Window,NULL,
  126.                      GTSL_Level,Red,TAG_DONE);
  127.    GG_SetGadgetAttrs(TestPro_Gadgets[TestPro_GREEN],TestPro.Window,NULL,
  128.                      GTSL_Level,Green,TAG_DONE);
  129.    GG_SetGadgetAttrs(TestPro_Gadgets[TestPro_BLUE],TestPro.Window,NULL,
  130.                      GTSL_Level,Blue,TAG_DONE);
  131.  
  132.    return TRUE;
  133. }
  134.  
  135. int RedHook(struct IntuiMessage *msg)
  136. {
  137.    Red=msg->Code;
  138.    SetRGB4(&TestPro.Window->WScreen->ViewPort,ActiveColor,Red,Green,Blue);
  139.  
  140.    return TRUE;
  141. }
  142.  
  143. int GreenHook(struct IntuiMessage *msg)
  144. {
  145.    Green=msg->Code;
  146.    SetRGB4(&TestPro.Window->WScreen->ViewPort,ActiveColor,Red,Green,Blue);
  147.  
  148.    return TRUE;
  149. }
  150.  
  151. int BlueHook(struct IntuiMessage *msg)
  152. {
  153.    Blue=msg->Code;
  154.    SetRGB4(&TestPro.Window->WScreen->ViewPort,ActiveColor,Red,Green,Blue);
  155.    return TRUE;
  156. }
  157.  
  158. #end_source
  159.  
  160.